﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using BrewXML.Core.Data;
using BrewXML.Core.Services;
using BrewXML.Core.Services.NavigationServices;
using Cirrious.CrossCore;
using Cirrious.MvvmCross.ViewModels;

namespace BrewXML.Core.ViewModels
{
    public class HomePageViewModel : BaseViewModel
    {
        #region View

       
        #endregion

        #region Properties

        #region Data

        private XMLData mdata=new XMLData();

        public XMLData Data
        {
            get
            {
                return mdata;
            }
            set
            {
                mdata = value;
                RaisePropertyChanged("Data");
            }
        }
        #endregion

        #region HOPS

        private List<HOP> mHops = new List<HOP>();

        public List<HOP> HOPS
        {
            get
            {
                return mHops;
            }
            set
            {
                mHops = value;
                RaisePropertyChanged("HOPS");
            }
        }
        #endregion

        #region GRAINS

        private List<GRAIN> mGrains = new List<GRAIN>();

        public List<GRAIN> GRAINS
        {
            get
            {
                return mGrains;
            }
            set
            {
                mGrains = value;
                RaisePropertyChanged("GRAINS");
            }
        }
        #endregion

        #region MISCS

        private List<MISC> mMiscs = new List<MISC>();

        public List<MISC> MISCS
        {
            get
            {
                return mMiscs;
            }
            set
            {
                mMiscs = value;
                RaisePropertyChanged("MISCS");
            }
        }
        #endregion

        #region STYLES

        private List<STYLE> mStyles = new List<STYLE>();

        public List<STYLE> STYLES
        {
            get
            {
                return mStyles;
            }
            set
            {
                mStyles = value;
                RaisePropertyChanged("STYLES");
            }
        }
        #endregion

        #endregion

        #region Command

        #region Navigate
        private MvxCommand<string> mNavigateCommand;

        public MvxCommand<string> NavigateCommand
        {
            get
            {
                return new MvxCommand<string>(NavigatePage);
            }
        }

        private void NavigatePage( string parameter)
        {
            switch (parameter)
            {
                case "ManagerDataPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.ManagerDataPage); break;
                case "HopsPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.HopsPage); break;
                case "GrainsPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.GrainsPage); break;
                case "MiscsPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.MiscsPage); break;
                case "StylesPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.StylesPage); break;
                case "RecipesPage":
                    Mvx.Resolve<INavigationService>().NavigateTo(PageNames.RecipesPage); break;
            }
           
        }
        #endregion

        #region Navigate
        private MvxCommand<object> mNavigateDetailCommand;

        public MvxCommand<object> NavigateDetailCommand
        {
            get
            {
                return new MvxCommand<object>(NavigateDetailPage);
            }
        }

        private void NavigateDetailPage(object parameter)
        {

            if (parameter is HOP)
            {
                Mvx.Resolve<HopDetailPageViewModel>().Hop = parameter as HOP;
                Mvx.Resolve<HopDetailPageViewModel>().EnableAppbar = true;
                Mvx.Resolve<INavigationService>().NavigateTo(PageNames.HopDetailPage);
            }
            if (parameter is GRAIN)
            {
                Mvx.Resolve<GrainDetailPageViewModel>().Grain = parameter as GRAIN;
                Mvx.Resolve<GrainDetailPageViewModel>().EnableAppbar = true;
                Mvx.Resolve<INavigationService>().NavigateTo(PageNames.GrainDetailPage);
            }
            if (parameter is MISC)
            {
                Mvx.Resolve<MiscDetailPageViewModel>().Misc = parameter as MISC;
                Mvx.Resolve<MiscDetailPageViewModel>().EnableAppbar = true;
                Mvx.Resolve<INavigationService>().NavigateTo(PageNames.MiscDetailPage);
            }
            if (parameter is STYLE)
            {
                Mvx.Resolve<StyleDetailPageViewModel>().Style = parameter as STYLE;
                Mvx.Resolve<StyleDetailPageViewModel>().EnableAppbar = true;
                Mvx.Resolve<INavigationService>().NavigateTo(PageNames.StyleDetailPage);
            }
                
        }
        #endregion
        #endregion

        #region Initialize

        public void Initialize()
        {
            
        }
        #endregion

        #region Constructors

        public HomePageViewModel()
        {
            
        }
        #endregion

    }
}
